﻿using System;
using NUnit.Framework;
using NMA.Domain.Model.Contract;
using NMA.Domain.Model;
using NMA.Infrastructure.NHibernate.DomainObject;
using NMA.Infrastructure.NHibernate.OrderByExpression;

namespace NMA.Infrastructure.NHibernate.Tests.OrderByExpression
{
    [TestFixture]
    public class SearchCategoryOrderByExpressionTest
    {
        private ICategory testingCategory;
        private IOrderByExpressionFactory orderByExprFactory;

        [SetUp]
        public void InitTest()
        {
            orderByExprFactory = new OrderByExpressionFactory();

            testingCategory = new Category()
            {
                Id = Guid.NewGuid(),
                Name = "testName",
                CreatedUser = "testUser",
                UpdatedUser = "testUser",
                CreatedDate = DateTime.Now,
                UpdatedDate = DateTime.Now,
            };
        }

        [Test]
        public void GetIdOrderExpressionTest()
        {
            var func = orderByExprFactory.CreateCategorySearchOrderBy(SearchCategoryOrderByType.Id);
            var result = func(testingCategory);
        }

        [Test]
        public void GetNameOrderExpressionTest()
        {
            var func = orderByExprFactory.CreateCategorySearchOrderBy(SearchCategoryOrderByType.Name);
            var result = func(testingCategory);
        }

        [Test]
        public void GetCreatedUserOrderExpressionTest()
        {
            var func = orderByExprFactory.CreateCategorySearchOrderBy(SearchCategoryOrderByType.CreatedUser);
            var result = func(testingCategory);
        }

        [Test]
        public void GetCreatedDateOrderExpressionTest()
        {
            var func = orderByExprFactory.CreateCategorySearchOrderBy(SearchCategoryOrderByType.CreatedDate);
            var result = func(testingCategory);
        }

        [TearDown]
        public void EndTest()
        {
            if (orderByExprFactory != null)
                GC.SuppressFinalize(orderByExprFactory);
        }
    }
}
